#include <iostream>
#include "Base/ThreadManager.h"
#include "Base/Log/LogDefine.h"
#include "Net/ConnectProcessor.h"
#include "Net/IOProcessor.h"
#include "Logic/LogicProcessor.h"
#include "LoginProcessor.h"
#include "Base/ProcessorManager.h"

int main()
{
	INIT_LOG(MoheServer, "MoheServer", LOG_DEBUG);

	CConnectProcessor *pProcessor = new CConnectProcessor();

	pProcessor->setProcessorType(PROCESSOR_TYPE::PROCESSOR_TYPE_CONNECT);
	pProcessor->initListen(50007);
	CProcessorManager::GetInstancePtr()->addProcessor(PROCESSOR_TYPE::PROCESSOR_TYPE_CONNECT, 0, pProcessor);

	CIOProcessor *pIOprocessor = new CIOProcessor();
	pIOprocessor->setProcessorType(PROCESSOR_TYPE::PROCESSOR_TYPE_IO);
	CProcessorManager::GetInstancePtr()->addProcessor(PROCESSOR_TYPE::PROCESSOR_TYPE_IO, 0, pIOprocessor);

	CLoginProcessor *pLoginProcessor = new CLoginProcessor();
	pLoginProcessor->setProcessorType(PROCESSOR_TYPE::PROCESSOR_TYPE_LOGIN);
	CProcessorManager::GetInstancePtr()->addProcessor(PROCESSOR_TYPE::PROCESSOR_TYPE_LOGIN, 0, pLoginProcessor);

	auto f = (std::bind(&CConnectProcessor::tick, pProcessor));
	auto f1 = (std::bind(&CIOProcessor::tick, pIOprocessor));
	auto f2 = std::bind(&CLoginProcessor::tick, pLoginProcessor);

	CThreadManager::GetInstancePtr()->init(5);
	CThreadManager::GetInstancePtr()->bindFunction(f, 50);
	CThreadManager::GetInstancePtr()->bindFunction(f1, 50);
	CThreadManager::GetInstancePtr()->bindFunction(f2, 500);

	std::cout << "Hello Mohe!" << std::endl;

	pLoginProcessor->init();

	while (true)
	{

	}
}